package me.zk;

/**
 * @Author: zhang kai
 * @Date: 2022/12/02
 * @Description:
 */
public class Practice1 {


    public static void main(String[] args) {
        int[] array = new int[]{1,2,3,4,5,6};
        int left = 0;
        int right = array.length -1;
        int a = 10;
        while (left <= right ) {
            int m = (left + right) /2;
            if (array[m] == a) {
                System.out.println(m);
                break;
            } else if (array[m] > a) {
                right = m -1;
            } else {
                left = m + 1;
            }
        }
        if (left > right) {
            System.out.println("未找到");
        }
    }

}
